package org.artifact.core.plugin.netty.server;

import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
import org.artifact.core.plugin.netty.handler.WebSocketHandler;

/**
 * @author : SandKing
 * @CreateDate : 2020/3/25 15:42
 * @Description ：Please describe this document
 */
public class NettyWebSocketServer extends NettyTcpServer {
	private static final String web_socket_Path = "/ws";


	@Override
	public void buildChannelPipeline(ChannelPipeline pipeline) {
		super.buildChannelPipeline(pipeline);
		pipeline.addLast(new HttpServerCodec());
		pipeline.addLast(new ChunkedWriteHandler());
		pipeline.addLast(new HttpObjectAggregator(65535));
		pipeline.addLast(new WebSocketServerProtocolHandler(web_socket_Path));
		pipeline.addLast(new WebSocketHandler());
	}
}
